package com.todo.event.activity.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2025/1/15 13:43
 * @description
 */
@Getter
@AllArgsConstructor
public enum ExecuteRecordStatusEnum {

    POST(1, "POST", "提交"), // 暂时不使用，暂时没有预提交场景，创建即执行中
    EXECUTING(2, "EXECUTING", "执行中"),
    SUCCESS(3, "SUCCESS", "执行完成"),
    FAILED(4, "FAILED", "执行失败"),
    ERROR(5, "ERROR", "执行异常"),
    RETRY_ERROR(6, "RETRY_ERROR", "重试异常"),
    ;

    private static Map<Integer, ExecuteRecordStatusEnum> typeMap = Arrays
            .stream(ExecuteRecordStatusEnum.values())
            .collect(Collectors.toMap(ExecuteRecordStatusEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static ExecuteRecordStatusEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
